Using a tile atlas

A tile atlas is an image that contains several smaller images. Use a tile atlas to improve application framerate by decreasing the number of texture switches that your application must make during runtime.

To use a tile atlas:

  1. Create a tile atlas in a third-party application.
    When creating a tile atlas keep in mind:
  2. In Kanzi Studio in the 资产 (Assets) click 导入资产 (Import Assets) and import the tile atlas.
    For example, you can import this tile atlas.

  3. Import and configure the material that enables you to set which part of the tile atlas you want to draw:
    1. Download the TileAtlas.zip file, which contains the TileAtlas material type.
    2. In Kanzi Studio in the 素材库 (Library) right-click 材质和纹理 (Materials and Textures), select 从磁盘加载材质类型 (Load Material Type From Disk), and import the TileAtlas material type.
    3. In the 素材库 (Library) > 材质和纹理 (Materials and Textures) > 材质 (Materials) select the TileAtlasMaterial material and in the 属性 (Properties) set the 混合模式 (Blend Mode) property to 阿尔法: 预乘 (Alpha: Premultiplied).
      The fragment shader for this material type expects premultiplied alpha so that it can blend the source fragment with the destination framebuffer.
  4. In the 素材库 (Library) 按下 Alt 并右键点击 材质和纹理 (Materials and Textures), select 材质笔刷 (Material Brush), and in the 属性 (Properties) set the 材质 (Material) property to the TileAtlasMaterial material.
    You use this brush to draw images from a tile atlas.
  5. In the 工程 (Project) create or select a node that you want to use to show an image from a tile atlas, in the 属性 (Properties) add the 前景笔刷 (Foreground Brush) property, and set it to the 材质笔刷 (Material Brush) that you created.
    For example, create an 2D 空节点 (Empty Node 2D) node.
  6. In the 素材库 (Library) > 材质和纹理 (Materials and Textures) > 材质 (Materials) select the TileAtlasMaterial material and from the 属性 (Properties) drag these properties to the node that you created:
  7. In the 工程 (Project) select the node that you created and set these properties:
    建议

    You can use a tile atlas to show a different image for different states of a telltale. Create a 状态机 (State Manager) and in each state set the properties that change between the states, such as OffsetInTileAtlas and PrimaryColor. See 使用状态机 and 教程:创建组合仪表指示灯.

另请参阅

调整数据大小

压缩纹理

过滤纹理

使用 mipmap

图像和纹理最佳实践

排除应用程序的性能问题

材质类型和材质

状态机